﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Pipeline;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;

namespace MouldingAndMillwork.SSIS
{
    public partial class SSISUtility
    {
        #region CLASS: Messaging
        public class Messaging
        {
            #region Class Variables
            private static Hashtable _warningsFireAgain = new Hashtable();
            #endregion

            #region SSIS Messaging (output window)
            public static void PostError(IDTSComponentMetaData100 componentMetaData, string message)
            {
                bool cancel = false;
                componentMetaData.FireError(0, componentMetaData.Name, message, "", 0, out cancel);
            }

            public static void PostWarning(IDTSComponentMetaData100 componentMetaData, string message)
            {
                componentMetaData.FireWarning(0, componentMetaData.Name, message, "", 0);
            }

            public static void PostInformation(IDTSComponentMetaData100 componentMetaData, string message)
            {
                if ((Messaging._warningsFireAgain[message] == null) || ((bool)Messaging._warningsFireAgain[message]))
                {
                    bool bFireAgain = true;
                    componentMetaData.FireInformation(0, componentMetaData.Name, message, "", 0, ref bFireAgain);
                    Messaging._warningsFireAgain[message] = bFireAgain;
                }
            }
            #endregion
        }
        #endregion
    }
}
